﻿using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;

namespace BOMSConsoleService.Lib
{
    public enum MsgType{
        Error,
        Warning,
        Info
    }
    public static class Output
    {
        public static void Print(string str)
        {
            Print(MsgType.Info, str, false);
        }
        public static void PrintLine(string str)
        {
            Print(MsgType.Info, str, true);
        }
        public static void PrintLine(MsgType msgType, string str)
        {
            Print(msgType, str, true);
        }
        public static void Print(MsgType msgType, string str, bool IsWriteLine, ConsoleColor color = ConsoleColor.Gray)
        {
            switch(msgType)
            {
                case MsgType.Error:
                    Console.BackgroundColor= ConsoleColor.DarkRed;
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write(str);
                    break;
                case MsgType.Warning:
                    Console.BackgroundColor= ConsoleColor.DarkGreen;
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write(str);
                    break;
                default:
                    Console.BackgroundColor = ConsoleColor.Black;
                    Console.ForegroundColor = color;
                    Console.Write(str);break;
            }
            CosoleStyleReset();//恢复默认
            if (IsWriteLine) Console.WriteLine(string.Empty);
        }
        private static void CosoleStyleReset()
        {
            Console.BackgroundColor =  ConsoleColor.Black;
            Console.ForegroundColor = ConsoleColor.Gray;
        }
    }
}
